-
Notifications
You must be signed in to change notification settings - Fork 11
👌 IMPROVE: Add jsonc #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I was using many other scopes/syntaxes with scopessytaxes |
|
I was thinking if we should add all those syntaxes. Most people will mostly encounter only sublime settings, keymap and sublime project files. I think we should add them. :) |
|
I should probably mention in the README that the PackageDev package needs to be installed. |
|
Just so you know, I haven't forgotten about this PR. I was looking at a way to not have PackageDev as a requirement for LSP-json to work. The replacement are JSON schema files... :) JSON schemas will give the possibility to have autocomplete in other plugin settings files as long as the have a defined schema. :) LSP-json will have its own JSONC syntax file that will come with this package, and will be assigned to all sublime, settings, theme, completions, keymaps, files... So no need to have 10 different scopes in the config for Here is an example of how it works. I am still working on this, so expect something like this in the future. |
| @@ -0,0 +1,143 @@ | |||
| %YAML 1.2 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the point of this sublime-syntax file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think He doesn't want this plugin to depend on PackageDev so he creates it for sublime-related files. Otherwise, users can directly use #6 (comment) in their settings to activate LSP-json.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that is the point.
LSP-json will have its own JSONC syntax file that will come with this package, and will be assigned to all sublime, settings, theme, completions, keymaps, files... So no need to have 10 different scopes in the config for jsonc. There will be just one and that is source.jsonc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like it :( The PackageDev syntaxes have great highlighting. What's more is that there is already a syntax for JSON with comments at Packages/JavaScript/JSON.sublime-syntax.
Why does this plugin need to depend on PackageDev in the first place?
Also, why not write a language server for json-with-comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not put jsonc instead of json for the languageId? Wouldn't that make the json-language-server shut up about comments? https://github.com/sublimelsp/LSP-json/blob/master/plugin.py#L85
jsonc documents additionally accept single line (//) and multi-line comments (/* ... */).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see now that this pull request modifies the languageId from json to jsonc. So that should already remove the errors about comments. So then why not use Packages/JavaScript/JSON.sublime-syntax? Remember that maintaining a custom JSON syntax is some serious maintainer burden...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember that maintaining a custom JSON syntax is some serious maintainer burden...
I don't like this solution either (maybe because I have PackageDev installed :D ), but...
So then why not use Packages/JavaScript/JSON.sublime-syntax?
ST's JSON doesn't differentiate json and jsonc since it treats everything as jsonc. If we do so, LSP will not treat a comma (and comment) in a JSON file as an error. If we want a way to differentiate them, then either via a 3rd-party (PackageDev) or creates our own...
Another way to not actually maintain the syntax "definition" is something like:
%YAML 1.2
---
name: JSONC
file_extensions:
- jsonc
- sublime-settings
- sublime-menu
- sublime-keymap
- sublime-mousemap
- sublime-theme
- sublime-build
- sublime-project
- sublime-completions
- sublime-commands
- sublime-macro
- sublime-color-scheme
- ipynb
- Pipfile.lock
scope: source.jsonc
contexts:
prototype:
- include: Packages/JavaScript/JSON.sublime-syntax#prototype
main:
- include: Packages/JavaScript/JSON.sublime-syntax#mainIt results in a base scope source.jsonc with other ....json subscopes.
But there is no guarantee that ST will chooses your syntax definition over PackageDev's (or other 3rd-party plugin's). I don't know how ST chooses the syntax when there are multiple qualified candidates.
|
What about having an alternative, glob-based activation of the language server? So for this server configuration would look something like: "languages": [
{
"languageId": "json",
"scopes": ["source.json"],
"syntaxes": [
"Packages/JavaScript/JSON.sublime-syntax",
"Packages/JSON/JSON.sublime-syntax"
],
},
{
"languageId": "jsonc",
"scopes": ["source.json"],
"path_match": [
"*.sublime_settings",
"*.sublime_keymap"
]
}
]
|
|
I will close this PR in favor of #8 |

closes #2